Jump to content

Capture and Recording

From RidgeRun Developer Wiki

Follow us on: YouTube Twitter LinkedIn Email Share this page

Share This Page






Problems running the pipelines shown on this page? Please see our GStreamer Debugging guide for help .


Capture and Recording

To capture video from a camera, it is possible to use the v4l2src plugin. The pipeline follows the general structure below.

gst-launch-1.0  v4l2src device=/dev/videoX ! $CAPS ! queue ! v4l2h264enc ! h264parse ! $MUX ! filesink location=$FILE

MP4

To save the output as an MP4 file, use the following pipeline as reference.

gst-launch-1.0 -e v4l2src device=/dev/video6 ! video/x-raw,width=1920,height=1080 ! queue ! v4l2h264enc ! h264parse ! qtmux ! filesink location=output.mp4

TS

To save the output as a TS file, use the following pipeline as reference.

gst-launch-1.0 -e v4l2src device=/dev/video6 ! video/x-raw,width=1920,height=1080 ! queue ! v4l2h264enc ! h264parse ! mpegtsmux ! filesink location=output.ts

MKV

To save the output as an MKV file, use the following pipeline as reference.

gst-launch-1.0 -e v4l2src device=/dev/video6 ! video/x-raw,width=1920,height=1080 ! queue ! v4l2h264enc ! h264parse ! matroskamux ! filesink location=output.mkv

Video Recording

Video recording examples get a video test pattern, encode and containerize it and save it to a file. The encoder might be H.264 or H.265 as shown below.

H.264

gst-launch-1.0 videotestsrc is-live=true ! video/x-raw,width=1920,height=1080 ! queue ! v4l2h264enc ! h264parse ! queue ! qtmux ! filesink location=output.mp4 -e

H.265

gst-launch-1.0 videotestsrc is-live=true pattern=ball ! video/x-raw,width=1920,height=1080 ! queue ! v4l2h265enc ! h265parse ! queue ! matroskamux ! filesink location=output.mkv

Audio Recording

An audio-only recording pipeline looks like the one below. This pipeline records audio from a audiotestsrc encoded in MP3 format. You can change the encoder to any audio encoder available.

gst-launch-1.0 audiotestsrc ! lamemp3enc ! filesink location=output.mp3

NOTE: For Verdin i.M95 EVK if you want to use the headphones, verify the position of the S3 switch. Check Verdin Audio Switch section.

Audio and Video Recording

The following pipeline records audio and video from the camera and microphone.

gst-launch-1.0 -e -v   v4l2src device=/dev/video6 !     video/x-raw,width=1920,height=1080,framerate=30/1,format=NV12 !     queue ! imxvideoconvert_g2d !     v4l2h264enc ! h264parse ! queue ! mux.   alsasrc device=hw:0,0 !     audio/x-raw,format=S16LE,rate=48000,channels=2 !     queue ! audioconvert ! audioresample !     avenc_aac ! aacparse ! queue ! mux.   mp4mux name=mux !     filesink location=recording.mp4










Cookies help us deliver our services. By using our services, you agree to our use of cookies.